package co.uk.j_wp.games.topdowngame.input;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyMap implements KeyListener {

	public boolean up;
	public boolean left;
	public boolean right;
	public boolean down;

	@Override
	public void keyPressed(KeyEvent e) {
		updateKeys(e.getKeyCode(), true);
	}

	private void updateKeys(int keyCode, boolean b) {
		switch (keyCode) {
		case KeyEvent.VK_W:
		case KeyEvent.VK_UP:
			up = b;
			break;
		case KeyEvent.VK_A:
		case KeyEvent.VK_LEFT:
			left = b;
			break;
		case KeyEvent.VK_D:
		case KeyEvent.VK_RIGHT:
			right = b;
			break;
		case KeyEvent.VK_S:
		case KeyEvent.VK_DOWN:
			down = b;
			break;
		}
	}

	@Override
	public void keyReleased(KeyEvent e) {
		updateKeys(e.getKeyCode(), false);
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub

	}

}
